<?php
	/**
	*  建立包括下载提交访问等多功能类
	*/
	function doRequest($method, $url, $vars) {
	    $ch = curl_init();
	    $user_agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727;)";
	    curl_setopt($ch, CURLOPT_URL, $url);
	    curl_setopt($ch, CURLOPT_HEADER, False);
	    curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
	    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
	    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	   // curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
	   // curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
	    if ($method == 'POST') {
	        curl_setopt($ch, CURLOPT_POST, 1);
	        curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
	    }
	    $data = curl_exec($ch);
	    curl_close($ch);
	    
	    if ($data) {
			return $data;
	    } else {
	    	//出错
	        die($ch);
	    }
	}
	
	
	function curl_get($url) {
	    return doRequest('GET', $url, 'NULL');
	}
	
	
	function curl_post($url, $vars) {
	    return doRequest('POST', $url, $vars);
	}

?>